<?php
class QAdminUserDragonTool
{
	//Insert and update to table Admins of Dragontool
	
	static $_table = 'admins';
	
	public function __construct()
	{
		$this->_db		= new Common_Db('config_dragontool');
	}
	
	public function updatePassword($p_userName,$strPassOld, $strPassNew )
	{
		$strQuery	= 'SELECT * FROM '. self::$_table.' WHERE admin_username="'. $p_userName . '";';
		$arrResult	= $this->_db->fetchAll($strQuery);
		
		$arrResult[0]['admin_pwd'] = $strPassNew;
		$result = $this->update($arrResult[0], $p_userName);
		$this->_db->closeConnection();
		return $result;
	}
	
	public function insert($p_arrParams)
	{
		$result = $this->_db->insert(self::$_table, $p_arrParams);
		$this->_db->closeConnection(); 
		return $result;
	}
	
	public function update($p_arrParams, $p_strUsername)
	{
		$result = $this->_db->update(self::$_table, $p_arrParams, 'admin_username="'. $p_strUsername .'"');
		$this->_db->closeConnection();
		return $result;
	}
}
?>